<!doctype html>
<html>
  <head>
    <title>Notifications: Verifying the exception throwing behavior, when data set invalid value such as a method.</title>
    <script src="../resources/testharness.js"></script>
    <script src="../resources/testharnessreport.js"></script>
    <script src="../serviceworker/resources/test-helpers.js"></script>
    <script src="resources/test-helpers.js"></script>
  </head>
  <body>
    <script>
      // Tests that the showNotification() function rejects the returned promise with a
      // DataCloneError when data set invalid data such as a method.
      async_test(function(test) {
          var scope = 'resources/scope/' + location.pathname,
              script = 'instrumentation-service-worker.js';

          testRunner.setPermission('notifications', 'granted', location.origin, location.origin);

          getActiveServiceWorkerWithMessagePort(test, script, scope).then(function(workerInfo) {
              assert_inherits(workerInfo.registration, 'showNotification', 'showNotification() must be exposed.');
              workerInfo.registration.showNotification(scope, {
                  data: function() { return 1; }
              }).then(unreached_fulfillment(test))
                .catch(function(error) {
                    assert_equals(error.name, 'DataCloneError');
                    test.done();
                });
          }).catch(unreached_rejection(test));

      }, 'showNotification() must reject if data is invalid value.');
    </script>
  </body>
</html>
